﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Workflow.Activities;
using CommonLibrary.Wf.Common;
using CommonLibrary.DataModel.Basic;

namespace CommonLibrary.Wf.InterFace
{
    [ExternalDataExchange()]
    public interface IWfExchange
    {
        /// <summary>
        /// 通知
        /// </summary>
        /// <param name="instanceID">实例编码</param>
        /// <param name="clrxx">处理者信息</param>
        /// <param name="fqrxx">发起人信息</param>
        /// <param name="taskName">任务名称</param>
        /// <param name="infoMethod">通知方式</param>
        /// <param name="isSprw">是否为审批任务</param>
        /// <returns></returns>
        void 通知(Guid instanceID, ChoiceClrxx clrxx, UserEntity fqrxx,
            string taskName, TipEnum infoMethod, ChoiceOne isSprw);

        /// <summary>
        /// 结束流程
        /// </summary>
        /// <param name="instanceID"></param>
        void 结束流程(Guid instanceID, TaskResult insResult);

        /// <summary>
        /// 等待审批完成事件
        /// </summary>
        event System.EventHandler<WaitArgs> 等待审批完成Event;

        /// <summary>
        /// 等待完成事件
        /// </summary>
        event EventHandler<WaitArgs> 等待完成事件Event;

        /// <summary>
        /// 发起者提交事件(使用于回退以后)
        /// </summary>
        event EventHandler<WaitReStartArgs> 发起者提交Event;

        /// <summary>
        /// 审批提交
        /// </summary>
        /// <param name="instanceId"></param>
        /// <param name="result"></param>
        /// <param name="otherInfo">其他相关信息</param>
        /// <returns></returns>
        string 审批提交(Guid instanceId, string result, object otherInfo);

        /// <summary>
        /// 完成提交
        /// </summary>
        /// <param name="instanceId"></param>
        /// <returns></returns>
        string 完成提交(Guid instanceId);

        /// <summary>
        /// 回退以后的重新提交
        /// </summary>
        /// <param name="instanceId"></param>
        /// <param name="sp"></param>
        /// <returns></returns>
        string 回退以后的重新提交(Guid instanceId, Dictionary<string, object> sp);
    }

    /// <summary>
    /// 等待提交任务的事件
    /// </summary>
    [Serializable()]
    public class WaitArgs : ExternalDataEventArgs
    {
        public WaitArgs(Guid instanceId)
            : base(instanceId)
        {
        }

        /// <summary>
        /// 处理结果
        /// </summary>
        public string exResult { set; get; }

        /// <summary>
        /// 其他相关信息
        /// </summary>
        public object otherInfo { set; get; }
    }

    /// <summary>
    /// 等待重新开始的事件
    /// </summary>
    [Serializable()]
    public class WaitReStartArgs : ExternalDataEventArgs
    {
        public WaitReStartArgs(Guid instanceId)
            : base(instanceId)
        {
        }

        /// <summary>
        /// 流程参数
        /// </summary>
        public Dictionary<string, object> insParamater { set; get; }
    }
}
